Skip to content

gh-71086: Document negative offset support in struct.pack_into() and unpack_from()#153650

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:doc-struct-negative-offset
Jul 14, 2026
Merged

gh-71086: Document negative offset support in struct.pack_into() and unpack_from()#153650
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:doc-struct-negative-offset

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

struct.pack_into() and struct.unpack_from() (and the corresponding
Struct methods) accept a negative offset, counting from the end of the
buffer, but this was never documented.

Document it in Doc/library/struct.rst and in the docstrings of all four
callables. Also reword the module-level unpack_from() docstring: the old
"The buffer's size, minus offset, must be at least calcsize(format)" is
inaccurate for a negative offset, so it now reads "The buffer must contain at
least calcsize(format) bytes starting at offset".

…) and unpack_from()

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33560504 | 📁 Comparing c30d567 against main (adebb68)

  🔍 Preview build  

1 file changed
± library/struct.html

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) July 13, 2026 08:54
@serhiy-storchaka serhiy-storchaka merged commit 1706d14 into python:main Jul 14, 2026
110 of 112 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jul 14, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1706d14a2a1f009f786b8d7599e53c168b0392e0 3.14

@bedevere-app

bedevere-app Bot commented Jul 14, 2026

Copy link
Copy Markdown

GH-153699 is a backport of this pull request to the 3.15 branch.

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1706d14a2a1f009f786b8d7599e53c168b0392e0 3.13

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant